package com.cl.ks.repository;

import com.cl.ks.entity.KsFilterStatistics;
import com.cl.mvc.repository.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

@Repository
public interface KsFilterStatisticsRepository extends BaseRepository<KsFilterStatistics> {

    @Query(nativeQuery = true,value = "select * from ks_filter_statistics where rule_id = :ruleId order by create_time desc limit 1")
    KsFilterStatistics getKsFilterStatisticsByRuleId(Integer ruleId);

    @Modifying
    @Transactional
    @Query(nativeQuery = true,value = "delete from ks_filter_statistics where rule_id=:ruleId")
    int deleteByRuleId(Integer ruleId);
}
